package com.sgolub.commanndsonline.dao.ref.distinct;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.sgolub.commanndsonline.domain.ref.distinct.RefDistinctLocality;

@Repository
public class RefDistinctLocalityDAOImpl implements RefDistinctLocalityDAO {

    @Autowired
    private SessionFactory sessionFactory;
	
	@SuppressWarnings("unchecked")
	public List<RefDistinctLocality> list() {
		System.out.println("List<RefDistinctLocality> list()");

		return sessionFactory.getCurrentSession().getNamedQuery("findDistinctLocality")
				.setString("paramMatchString", "%")
				.list();
	}
	
	@SuppressWarnings("unchecked")
	public List<RefDistinctLocality> match(String matchString){
		
		System.out.println("List<RefDistinctLocality> match(param) param = " + matchString);
		
		return sessionFactory.getCurrentSession().getNamedQuery("findDistinctLocality")
				.setString("paramMatchString", "%" + matchString + "%").list();
	}

}
